package simplecoder.domain;

import java.util.ArrayList;
import java.util.List;

public class Pojo {
	
	private String packName;
	private String name;
	private List<Field> fields;
	
	public Pojo(String name, String packName){
		this.packName = packName;
		this.name = name;
	}
	
	public void addField(String name, String type){
		if(fields==null){
			fields = new ArrayList<Field>();
		}
		Field field = new Field();
		field.setName(name);
		field.setTitle(name);
		field.setType(type);
		fields.add(field);
	}
	
	public String getName() {
		return name;
	}
	
	public String getPackName() {
		return packName;
	}
	
	public String getClassName() {
		return packName+"."+name;
	}
	
	public List<Field> getFieldList(){
		return fields;
	}
	
	public void addGridField(String name){
		for (Field f : fields) {
			if(f.getName().equals(name)){
				f.setGrid(true);
			}
		}
	}
	
	public void addEditField(String name){
		for (Field f : fields) {
			if(f.getName().equals(name)){
				f.setEdit(true);
			}
		}
	}
}
